<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        /**
         * 数值转换函数
         */
        var num1 = Number(true);//1 false为0
        var num2 = Number("hi"); //Nan

        var num3 = Number("10"); //10
        var num4 = Number("-10"); //-10
        //前边0会被忽略掉
        var num5 = Number("010"); //10
        var num6 = Number("-010"); //-10

        // 转换浮点数
        var num7 = Number("1.0"); //1
        //同样忽略前导0
        var num8 = Number("01.0"); //1

        //十六进制数据会转化为十进制
        var num9 = Number("0xf");//15

        console.log("num1: " + num1);//1 false为0
        console.log("num2: " + num2);
        console.log("num3: " + num3);
        console.log("num4: " + num4);
        console.log("num5: " + num5);
        console.log("num6: " + num6);
        console.log("num7: " + num7);
        console.log("num8: " + num8);
        console.log("num9: " + num9);

    </script>
</head>
<body>

</body>
</html>